home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / ActionWall.as next >
Encoding:
Text File  |  2013-04-24  |  3.6 KB  |  123 lines

  1. class ActionWall extends State
  2. {
  3.    var mcRef;
  4.    var nType;
  5.    var nSwitchRate;
  6.    var nLife;
  7.    static var sLINKAGE_NAME_DOOR = "mcDoor90";
  8.    static var sLINKAGE_NAME_DOOR_INVERSE = "mcDoor90Inverse";
  9.    static var sLINKAGE_NAME_REVOLVER = "mcRevolver";
  10.    static var sLINKAGE_NAME_SLIDE_H = "mcSlideH";
  11.    static var sLINKAGE_NAME_SLIDE_V = "mcSlideV";
  12.    static var sSTATE_OPENED = "Opened";
  13.    static var sSTATE_CLOSED = "Closed";
  14.    static var sSTATE_OPENING = "Opening";
  15.    static var sSTATE_CLOSING = "Closing";
  16.    static var nCOUNTER = 0;
  17.    static var nMIN_TIME = 40;
  18.    static var nMAX_TIME = 120;
  19.    function ActionWall(_nType, _nX, _nY, _xScl)
  20.    {
  21.       super(CTRLGame.getRef().mcRef.attachMovie(this.getLinkage(_nType),"mcMovingWall" + ActionWall.nCOUNTER,CTRLGame.getRef().calculateDepth(_nY,CTRLGame.nMOVING_WALL_ADD + ActionWall.nCOUNTER)));
  22.       ActionWall.nCOUNTER = ActionWall.nCOUNTER + 1;
  23.       this.mcRef._x = _nX;
  24.       this.mcRef._y = _nY;
  25.       this.mcRef._xscale = _xScl;
  26.       var _loc7_ = CTRLGame.getRef().Maze.getTabIndex(this.mcRef._x,this.mcRef._y);
  27.       if(CTRLGame.getRef().Maze.isPieceFlipped(_loc7_))
  28.       {
  29.          this.mcRef._xscale = - this.mcRef._xscale;
  30.       }
  31.       this.nType = _nType;
  32.       this.setState(ActionWall.sSTATE_CLOSED);
  33.       this.nSwitchRate = Math.round(Math.random() * (ActionWall.nMAX_TIME - ActionWall.nMIN_TIME)) + ActionWall.nMIN_TIME;
  34.       this.nLife = this.nSwitchRate;
  35.    }
  36.    function cleanUp()
  37.    {
  38.       super.cleanUp();
  39.       this.mcRef.swapDepths(7777);
  40.       this.mcRef.removeMovieClip();
  41.    }
  42.    function get Type()
  43.    {
  44.       return this.nType;
  45.    }
  46.    function get Ref()
  47.    {
  48.       return this.mcRef;
  49.    }
  50.    function manageStaticState(_sNextState)
  51.    {
  52.       if(!Controller.getRef().isPaused() && !CTRLGame.getRef().Screen.isInMiniGame())
  53.       {
  54.          if(this.nLife > 0)
  55.          {
  56.             this.nLife = this.nLife - 1;
  57.          }
  58.          if(this.nLife == 0)
  59.          {
  60.             if(this.nType == CTRLGame.nREVOLVER_WALL)
  61.             {
  62.                if(CTRLGame.getRef().isOkayToTurnRevolver(this.mcRef.mcHit2,this.mcRef.mcHit2More))
  63.                {
  64.                   this.setState(_sNextState);
  65.                   this.nLife = this.nSwitchRate;
  66.                }
  67.             }
  68.             else if(CTRLGame.getRef().isOkayToTurn(this.mcRef.mcHit2))
  69.             {
  70.                this.setState(_sNextState);
  71.                this.nLife = this.nSwitchRate;
  72.             }
  73.          }
  74.       }
  75.    }
  76.    function getLinkage(_nType)
  77.    {
  78.       if(_nType == CTRLGame.nTURN_WALL)
  79.       {
  80.          var _loc3_ = ActionWall.sLINKAGE_NAME_DOOR;
  81.       }
  82.       else if(_nType == CTRLGame.nREVOLVER_WALL)
  83.       {
  84.          _loc3_ = ActionWall.sLINKAGE_NAME_REVOLVER;
  85.       }
  86.       else if(_nType == CTRLGame.nSLIDE_WALL_H)
  87.       {
  88.          _loc3_ = ActionWall.sLINKAGE_NAME_SLIDE_H;
  89.       }
  90.       else if(_nType == CTRLGame.nTURN_WALL_INVERSE)
  91.       {
  92.          _loc3_ = ActionWall.sLINKAGE_NAME_DOOR_INVERSE;
  93.       }
  94.       else
  95.       {
  96.          _loc3_ = ActionWall.sLINKAGE_NAME_SLIDE_V;
  97.       }
  98.       return _loc3_;
  99.    }
  100.    function Opened()
  101.    {
  102.       this.manageStaticState(ActionWall.sSTATE_CLOSING);
  103.    }
  104.    function Closing()
  105.    {
  106.       if(this.stateFinished())
  107.       {
  108.          this.setState(ActionWall.sSTATE_CLOSED);
  109.       }
  110.    }
  111.    function Closed()
  112.    {
  113.       this.manageStaticState(ActionWall.sSTATE_OPENING);
  114.    }
  115.    function Opening()
  116.    {
  117.       if(this.stateFinished())
  118.       {
  119.          this.setState(ActionWall.sSTATE_OPENED);
  120.       }
  121.    }
  122. }
  123.